package com.bawei.module_service.ui

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bawei.lib_common.Router
import com.bawei.module_service.R
import com.bawei.module_service.adapter.MenuAdapter
import com.bawei.module_service.model.MenuItem

@Route(path = Router.Ui.ServiceFragment)
class ServiceFragment : Fragment() {
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?,
    ): View? {
        val inflate = inflater.inflate(R.layout.fragment_service, container, false)
        val recyclerView = inflate.findViewById<RecyclerView>(R.id.rv_service)
        // 这里设置为 3 列的网格布局，你可根据实际需求调整列数
        recyclerView.layoutManager = GridLayoutManager(requireContext(), 3)

        // 模拟数据，替换成你实际的图标资源和标题
        val menuItems = listOf(
            MenuItem(R.drawable.ic_car, "车辆管理"),
            MenuItem(R.drawable.ic_parking, "车位管理"),
            MenuItem(R.drawable.ic_visitor, "访客管理"),
            MenuItem(R.drawable.ic_repair, "维修管理"),
            MenuItem(R.drawable.ic_notice, "公告管理"),
            MenuItem(R.drawable.ic_attendance, "考勤管理"),
            MenuItem(R.drawable.ic_im, "即时通讯"),
            MenuItem(R.drawable.ic_device, "设备管理"),
            MenuItem(R.drawable.ic_house, "房源信息"),
            MenuItem(R.drawable.ic_property_repair, "物业报修"),
            MenuItem(R.drawable.ic_inspection, "巡检管理"),
            MenuItem(R.drawable.ic_month_card, "月卡会员")
        )

        val adapter = MenuAdapter(menuItems) {
            when (it.title) {
                "车辆管理" -> {
                    // 跳转到车辆管理页面
                    ARouter.getInstance().build(Router.Ui.VehicleActivity).navigation()
                }
                "车位管理" -> {
                    // 跳转到车位管理页面（示例：假设用 NavController 导航）
                    ARouter.getInstance().build(Router.Ui.CarSpaceActivity).navigation()
                }
                "访客管理" -> {
                    // 跳转到访客管理页面
                    ARouter.getInstance().build(Router.Ui.VisitorActivity).navigation()
                }
                "公告管理" -> {
                    // 跳转到公告管理页面
                    ARouter.getInstance().build(Router.Ui.NoticeActivity).navigation()
                }
                "考勤管理" -> {
                    ARouter.getInstance().build(Router.Ui.SignActivity).navigation()
                }
                "物业报修" -> {
                    ARouter.getInstance().build(Router.Ui.DemoActivity).navigation()
                }
                "维修管理" -> {
                    ARouter.getInstance().build(Router.Ui.RepairTextActivity).navigation()
                }
                "房源信息" -> {
                    // 跳转到房源管理页面
                    ARouter.getInstance().build(Router.Ui.HomeActivity).navigation()
                }
                "月卡会员"->{
                    ARouter.getInstance().build(Router.Ui.VipActivity).navigation()
                }
                "巡检管理"->{
                    ARouter.getInstance().build(Router.Ui.InspectionActivity).navigation()
                }
                "设备管理"->{
                    ARouter.getInstance().build(Router.Ui.EquipmentActivity).navigation()
                }
            }
        }
        recyclerView.adapter = adapter


        return inflate
    }



}